# Maintainer: Alexander Epaneshnikov <alex19ep@archlinux.org>
# Contributor: Brad Fanella <cesura@archlinux.org>
# Contributor: Martin Wimpress <code@flexion.org>

pkgbase=caja-extensions
pkgname=(caja-extensions-common caja-image-converter caja-open-terminal caja-sendto caja-share caja-wallpaper caja-xattr-tags)
pkgver=1.26.1
pkgrel=2
pkgdesc="Caja extensions"
url="https://mate-desktop.org"
arch=('loong64' 'x86_64')
license=('GPL')
depends=('caja' 'gettext' 'dbus-glib' 'imagemagick' 'samba')
makedepends=('python')
source=("https://pub.mate-desktop.org/releases/${pkgver%.*}/$pkgbase-$pkgver.tar.xz")
sha256sums=('589c19e3fa10242d6239a5ccb9585598436a56ebe94d2eb2a50b5950cce1d520')

build() {
    cd ${pkgbase}-${pkgver}

    # UPnP support needs to be ported to GUPnP 1.6
    # before it can be activated again
    # https://github.com/mate-desktop/caja-extensions/issues/110

    ./configure \
        --prefix=/usr \
        --disable-upnp \
        --disable-gksu

    #https://bugzilla.gnome.org/show_bug.cgi?id=656231
    sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool

    make
}

package_caja-extensions-common() {
    pkgdesc="Caja extensions (common files)"
    depends=()

    cd ${pkgbase}-${pkgver}
    make -C po DESTDIR="${pkgdir}" install
}

package_caja-image-converter() {
    pkgdesc="A Caja extension for simple image conversions"
    depends=('caja' 'caja-extensions-common' 'imagemagick')
    groups=('mate-extra')
    conflicts=('caja-image-converter-gtk3')
    replaces=('caja-image-converter-gtk3')

    cd ${pkgbase}-${pkgver}
    make -C image-converter DESTDIR="${pkgdir}" install
}

package_caja-open-terminal() {
    pkgdesc="A Caja extension for opening terminals in arbitrary local paths"
    depends=('caja' 'caja-extensions-common')
    groups=('mate-extra')
    conflicts=('caja-open-terminal-gtk3')
    replaces=('caja-open-terminal-gtk3')

    cd "${srcdir}/${pkgbase}-${pkgver}"
    make -C open-terminal DESTDIR="${pkgdir}" install
}

package_caja-sendto() {
    pkgdesc="A Caja extension for sending files"
    depends=('caja' 'caja-extensions-common' 'dbus-glib')
    groups=('mate-extra')
    optdepends=('pidgin: Support for sending to instant messaging networks.'
                'gajim: Support for sending to XMPP.')
    conflicts=('caja-sendto-gtk3')
    replaces=('caja-sendto-gtk3')

    cd ${pkgbase}-${pkgver}
    make -C sendto DESTDIR="${pkgdir}" install
}

package_caja-share() {
    pkgdesc="A Caja extension to quickly share a folder"
    depends=('caja' 'caja-extensions-common' 'samba')
    groups=('mate-extra')
    conflicts=('caja-share-gtk3')
    replaces=('caja-share-gtk3')    

    cd ${pkgbase}-${pkgver}
    make -C share DESTDIR="${pkgdir}" install
}

package_caja-wallpaper() {
    pkgdesc="A Caja extension to quickly set wallpaper"
    depends=('caja' 'caja-extensions-common')
    groups=('mate-extra')
    conflicts=('caja-wallpaper-gtk3')
    replaces=('caja-wallpaper-gtk3')
    
    cd ${pkgbase}-${pkgver}
    make -C wallpaper DESTDIR="${pkgdir}" install
}

package_caja-xattr-tags() {
    pkgdesc="A Caja extension to see tags stored on xattrs"
    depends=('caja' 'caja-extensions-common')
    groups=('mate-extra')
    
    cd ${pkgbase}-${pkgver}
    make -C xattr-tags DESTDIR="${pkgdir}" install
}
